import React, { Component } from 'react';
import {SingleInfo} from './common/Forminfo';
import {browserHistory,Link} from 'react-router';
import { connect } from 'react-redux';
import { ProfileInfo } from '../Redux/Actions/profileAction'

class MyAccount extends Component {

  componentWillMount(){
    this.props.dispatch(ProfileInfo(this.props.authReducer.user.data.token));
  }

  render() {
    const user = this.props.profileReducer.userinfo.data;
    if( user != undefined){
      return (
          <div className="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
            <div className="row">
              <ol className="breadcrumb">
                <li><a href="#"><span className="glyphicon glyphicon-home"></span></a></li>
                <li>我的账户</li>
              </ol>
            </div>
            <div className="row">
              <div className="col-lg-12">
                <div className="panel panel-default">
                  <div className="panel-heading">
                    我的账户详情
                    <Link className="pull-right btn btn-primary" style={{marginTop:"6px"}} to="/main/accountupdate">编辑</Link>
                  </div>
                  <div className="panel-body">
                    <div className="form-horizontal">
                      <SingleInfo label="真实名称" info={user.truename}/>
                      <SingleInfo label="手机号" info={user.phone}/>
                      <SingleInfo label="QQ" info={user.qq}/>
                    </div>
                  </div>
                </div>
              </div>
            </div>	
          </div>
      )
    }else{
      return <div></div>
    }
  }
}
export default connect((state) => {
    const { authReducer,profileReducer } = state;
    return {
        authReducer,profileReducer
    }
})(MyAccount); 